\section{线性化}
式\eqref{eqans1}包含两个二阶导，不能直接转化成状态空间。将式\eqref{eqans2}代入式\eqref{eqans1}得到
\begin{equation}\label{eqans4}
    (M+m\sin^2\theta)l\ddot{\theta}+ml\dot{\theta}^2\sin\theta\cos\theta-(M+m)g\sin\theta=F\cos\theta
\end{equation}
原式写成如下形式
\begin{align*}
    \dot{x}&=f_1(x,\dot{x},\theta,\dot{\theta})=\dot{x} \\
    \ddot{x}&=f_2(x,\dot{x},\theta,\dot{\theta})
    =\frac{0.5mg\sin 2\theta-ml\dot{\theta}^2\sin\theta}{M+m\sin^2\theta}
    +\frac{F}{M+m\sin^2\theta} \\
    \dot{\theta}&=f_3(x,\dot{x},\theta,\dot{\theta})=\dot{\theta} \\
    \ddot{\theta}&=f_4(x,\dot{x},\theta,\dot{\theta})
    =\frac{(M+m)g\sin\theta-0.5ml\dot{\theta}^2\sin 2\theta}{Ml+ml\sin^2\theta}
    +\frac{F\cos\theta}{Ml+ml\sin^2\theta} \\
\end{align*}
令
\[
    \boldsymbol{x}=\begin{bmatrix}
        x \\ \dot{x} \\ \theta \\ \dot{\theta}
    \end{bmatrix},
    \boldsymbol{y}=\begin{bmatrix}
        x \\ \theta
    \end{bmatrix},
    \boldsymbol{u}=[F]
\]
雅可比矩阵为如下形式
\[
    \mathbf{A}=\begin{bmatrix}
        \partialyx{f_1}{x_1} & \partialyx{f_1}{x_2} & \partialyx{f_1}{x_3} & \partialyx{f_1}{x_4} \\
        \partialyx{f_2}{x_1} & \partialyx{f_2}{x_2} & \partialyx{f_2}{x_3} & \partialyx{f_2}{x_4} \\
        \partialyx{f_3}{x_1} & \partialyx{f_3}{x_2} & \partialyx{f_3}{x_3} & \partialyx{f_3}{x_4} \\
        \partialyx{f_4}{x_1} & \partialyx{f_4}{x_2} & \partialyx{f_4}{x_3} & \partialyx{f_4}{x_4} \\
    \end{bmatrix}
\]
将式\eqref{eqans3}和式\eqref{eqans4}线性化分别得到
\[
    \partialyx{f_2}{x_1}\bigg|_{\boldsymbol{x}=\boldsymbol{0}}
    =\partialyx{f_2}{x_2}\bigg|_{\boldsymbol{x}=\boldsymbol{0}}
    =\partialyx{f_2}{x_4}\bigg|_{\boldsymbol{x}=\boldsymbol{0}}=0,
    \partialyx{f_2}{x_3}\bigg|_{\boldsymbol{x}=\boldsymbol{0}}=\frac{mg}{M}
\]
\[
    \partialyx{f_4}{x_1}\bigg|_{\boldsymbol{x}=\boldsymbol{0}}
    =\partialyx{f_4}{x_2}\bigg|_{\boldsymbol{x}=\boldsymbol{0}}
    =\partialyx{f_4}{x_4}\bigg|_{\boldsymbol{x}=\boldsymbol{0}}=0,
    \partialyx{f_4}{x_3}\bigg|_{\boldsymbol{x}=\boldsymbol{0}}=\frac{Mg+mg}{Ml}
\]
于是
\begin{align}
    \ddot{x}=\frac{mg}{M}\theta+\frac{1}{M}F \label{eqlin1}\\
    \ddot{\theta}=\frac{Mg+mg}{Ml}\theta+\frac{1}{Ml}F \label{eqlin2}
\end{align}
建立状态空间模型
\begin{align*}
    &\dot{\boldsymbol{x}}=\mathbf{A}\boldsymbol{x}+\mathbf{B}u \\
    &\boldsymbol{y}=C\boldsymbol{x}
\end{align*}
\[
    \begin{bmatrix}
        \dot{x}       \\
        \ddot{x}      \\
        \dot{\theta}  \\
        \ddot{\theta} \\
    \end{bmatrix}=\begin{bmatrix}
        0 & 1 & 0 & 0 \\
        0 & 0 & \frac{mg}{M} & 0 \\
        0 & 0 & 0 & 1 \\
        0 & 0 & \frac{Mg+mg}{Ml} & 0 \\
    \end{bmatrix}\begin{bmatrix}
        x             \\
        \dot{x}       \\
        \theta        \\
        \dot{\theta}  \\
    \end{bmatrix}+\begin{bmatrix}
        0 \\
        \frac{1}{M} \\
        0 \\
        \frac{1}{Ml} \\
    \end{bmatrix}u
\]
